#include <stdio.h>
#include <stdlib.h>


int main(void)
{
	FILE *f_rice, *f_cubes, *f_diff;
	char ligne_rice[10], ligne_cubes[10];
	int i, int_rice, int_cubes;

	f_rice=fopen("Histo_rice.txt", "r");
	f_cubes=fopen("Histo_cubes.txt", "r");
	f_diff=fopen("Histo_diff.txt", "w+");
	printf("Fichiers ouverts.\n");
	
	if (f_rice != NULL && f_cubes != NULL)
   {
   	for(i=0; i<255; i++)	
		{
			fgets(ligne_rice, 10, f_rice);
			int_rice=atoi(ligne_rice);
			printf("int_rice = %d\n", int_rice);
			fgets(ligne_cubes, 10, f_cubes);
			int_cubes = atoi(ligne_cubes);
			printf("int_cubes = %d\n", int_cubes);
			fprintf(f_diff, "%d\n", (int_rice-int_cubes));
		}
		printf("Fermeture fichiers...\n");
		fclose(f_rice);
		fclose(f_cubes);
		fclose(f_diff); 
		printf("Fichiers fermés.\n");
   }
   else	printf("Impossible d'ouvrir un fichier");

	return 1;
}
